using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MvcContrib.PortableAreas;
using System.Web.Mvc;
using System.Configuration;
using System.Web.Routing;

namespace SFS.SampleApp.Web.Mvc
{
    public class SFSSampleAppWebMvcRegistration : PortableAreaRegistration
    {

        public override void RegisterArea(System.Web.Mvc.AreaRegistrationContext context, IApplicationBus bus)
        {
           
            
            context.MapRoute("SFSSampleApp_ResourceRoute", "SFSSampleApp/resource/{resourceName}",
                new { controller = "EmbeddedResource", action = "Index" },
                new string[] { "MvcContrib.PortableAreas" });

            context.MapRoute("SFSSampleApp_ResourceImageRoute", "SFSSampleApp/images/{resourceName}",
                new { controller = "EmbeddedResource", action = "Index", resourcePath = "images" },
                new string[] { "MvcContrib.PortableAreas" });

            context.MapRoute("SFSSampleApp", "SFSSampleApp/{controller}/{action}",
                new { controller = "SFSSampleApp", action = "index" },
                new string[] { "SFS.SampleApp.Web.Mvc.Controllers" });
            context.MapRoute(
              "SFSSampleApp_Id", // Route name
              "SFSSampleApp/{controller}/{action}/{id}", // URL with parameters
              new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                new string[] { "SFS.SampleApp.Web.Mvc.Controllers" } // Parameter defaults
                );

            context.MapRoute(
               "SFSSampleApp_AutoCompleteTest", // Route name
               "SFSSampleApp/{controller}/AutoCompleteResult/{searchText}", // URL with parameters
               new { controller = "Home", action = "AutoCompleteResult", searchText = UrlParameter.Optional },
                new string[] { "SFS.SampleApp.Web.Mvc.Controllers" } // Parameter defaults
           );
            //context.MapRoute(
            //    "SFSSampleApp_UseMode_Item", // Route name
            //    "SFSSampleApp/{controller}/{action}/{id}/usemode:{usemode}", // URL with parameters
            //    new { controller = "Home", action = "Index", id = UrlParameter.Optional, usemode = UrlParameter.Optional } // Parameter defaults
            //);

            //context.MapRoute(
            //    "SFSSampleApp_UseMode_List", // Route name
            //    "SFSSampleApp/{controller}/{action}/usemode:{usemode}", // URL with parameters
            //    new { controller = "Home", action = "Index", usemode = UrlParameter.Optional } // Parameter defaults
            //);
           // ControllerBuilder.Current.DefaultNamespaces.Add("SFS.SampleApp.Web.Mvc.Controllers");

            this.RegisterAreaEmbeddedResources();
            if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["AutoInjectPermissionsOnStartup"]))   
                SecuritySettings.PermissionsInitialization();
        
        }

        public override string AreaName
        {
            get
            {
                return "SFSSampleApp";
            }
        }
    }
}
